package edu.upenn.seas.peerreview

import java.io.Serializable
import scala.collection.immutable.HashSet
import scala.collection.immutable.HashMap
import scala.collection.Map

/* This file defines the common interface between the three layers. */

trait Id

object Id {
  @serializable object coordinatorId extends Id {
    override def toString = "COORDINATOR"
  }
}

trait Message extends Serializable
abstract class PRUIMessage extends Message                                     
case class AuditResult (ok:Boolean) extends PRUIMessage // PR to UI            
case class OKToReleaseLog () extends PRUIMessage        // UI to PR   
case class PleaseAudit (id:Id) extends PRUIMessage      // UI to PR   

object Source {  
  type Factory = (Id, Sink.T) => Source.T
  type T = (Id, Message) => Unit
}

object Sink {
  type T = (Id, Message) => Unit
}

// Call debug from your code: Debug.debug(tag)(msg)
object Debug {
  var debugLevel: List[String] = Nil
  def debug(tag: String)(msg: String): Unit = DebugImpl(tag)(msg)
  // The first argument is the channel (see command line), 
  // followed by list of tags that channel subscribes to.
  DebugImpl.watch("pr")("log", "auth")
  DebugImpl.watch("transport")("transport")
  DebugImpl.watch("smui")("appmessage", "actors", "battleship")
  DebugImpl.watch("smui-temp")("rpc", "nrpc")
}
